﻿/*
    a10_indexer @ https://gitee.com/zcatt/MyDemo2020
indexer的形式  ReturnType this[InType index]{...}
InType通常是整型, 但可以是其他类型

 */ 
using System;
using System.Collections;

public class MyDB
{
    Hashtable m_tbl = new Hashtable();

    public void Add(string key, string value)
    {
        m_tbl.Add(key, value);
    }

    public string this[string idx]
    {
        get
        {
            return (string)m_tbl[idx];
        }

        set
        {
            m_tbl[idx] = value;
        }
    }

}
class Program
{
    static void Main(string[] args)
    {
        MyDB db = new MyDB();
        db.Add("Mon", "Monday");
        db.Add("Wed", "Wednesday");
        db.Add("Fri", "Friday");

        Console.WriteLine(db["Mon"]);
        db["Tue"] = "Tuesday";
        Console.WriteLine(db["Tue"]);

        return;
    }
}
